package main

import (
	"fmt"
	"testing"

	"github.com/pkg/errors"
)

func fn() error {
	e1 := errors.New("error")
	e2 := errors.Wrap(e1, "wrap error")
	e3 := errors.Wrap(e2, "middle")
	return errors.Wrap(e3, "outer")
}

func TestingTest(t *testing.T) {
	// type stackTracer interface{
	// 	StackTrace() errors.StackTrace
	// }
	type stackTracer interface {
		StackTrace() errors.StackTrace
	}
	err, ok := errors.Cause(fn()).(stackTracer)
	if err, ok = err.(stackTracer); ok {
		for _, f := range err.StackTrace() {
			fmt.Printf("%+s:%d\n", f, f)
		}
	}
}
